package core;

import java.util.Random;

public class Room {
	public enum Type {
		kitchen, bedroom, living, hall, entrance
	}

	public Type type;

	public Square[] squares;

	public Room(Room.Type type) {
		this.type = type;

		this.squares = new Square[8];
		for (int i = 0; i < 8; i++)
			this.squares[i] = new Square(Square.Type.Clean);

		Random random = new Random();
		int next = Math.abs(random.nextInt()) % 8;
		if (this.type == Room.Type.kitchen)
			this.squares[next].type = Square.Type.Meal;
		else if (this.type == Room.Type.bedroom)
			this.squares[next].type = Square.Type.Smoking;
		else if (this.type == Room.Type.living)
			this.squares[next].type = Square.Type.Table;
		else
			this.squares[next].type = Square.Type.Flowers;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(((String) obj).equals("kitchen") && this.type == Room.Type.kitchen)
			return true;
		if(((String) obj).equals("bedroom") && this.type == Room.Type.bedroom)
			return true;
		if(((String) obj).equals("living") && this.type == Room.Type.living)
			return true;
		if(((String) obj).equals("hall") && this.type == Room.Type.hall)
			return true;
		if(((String) obj).equals("entrance") && this.type == Room.Type.entrance)
			return true;
		return false;
	}
}